package data;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: Vladimir
 * Date: 01.02.13 Time: 9:58
 */
public class CellMart {
    public static final String OUT_FOLDER = "data/import/cellmart/";
    public static final String BASE_FOLDER = "data/cellmart/";

    public static void main(String[] args) throws IOException, IllegalAccessException {
        for (String file : new File(BASE_FOLDER).list()) {
            if (file.endsWith(".xls")) {
                Map<String, List<ItemData>> data = ExtramobiExcel.parseItemData(BASE_FOLDER + file);
                for (String brand : data.keySet()) {
                    PrintStream out = new PrintStream(new FileOutputStream(OUT_FOLDER + brand));
                    out.println(CSVData.getHeader());
                    for (ItemData item : data.get(brand)) {
//                        if (item.category) {
//                            putCatSort(item.name);
//                            item.sort = getSort(item.name);
//                        }
//                        Map<String, String> props = new HashMap<String, String>();
//                        props.put("item.order.list", getModelList(item.brand + " " + item.model));
//                        ExtramobiNew.filterItem(item, commonProps, true);
//                        ExtramobiNew.filterItem(item, props, false);
//                        item.sort = getSort(item.name, item.article);
                        out.println(item);
                    }
                    out.close();
                }
            }
        }
    }
}
